Skip to content

Conversation

@zharinov
Copy link
Member

@zharinov zharinov commented Jan 5, 2026

Summary

  • Add Trampoline bytecode instruction for universal entry preamble
  • Move Obj/EndObj from definitions to call sites (call-site scoping)
  • Add universal preamble that wraps every entrypoint with Obj → Trampoline → EndObj → Return
  • Fix EndObj materializer to preserve pending values for non-struct results

Why

Fixes Bug 3: mixed captured/uncaptured sibling refs were losing data at runtime.

Before: A = (program (B) @b (C)) produced {b: {x: ...}}y from C was missing.
After: produces {b: {x: ...}, y: ...} — both captured and uncaptured refs work correctly.

The root cause was that definitions decided whether to wrap with Obj/EndObj based on their own captures, but the correct behavior depends on how the definition is called:

  • Captured ref (B) @b → needs isolated scope
  • Uncaptured ref (B) → captures should bubble to parent

Notes

@zharinov zharinov force-pushed the fix/call-site-scoping branch 5 times, most recently from 4057723 to 49f75b2 Compare January 5, 2026 13:35
- Definitions are normalized (no Obj/EndObj wrapper)
- Call sites decide scoping based on capture and return type
- Universal preamble wraps every entrypoint: Obj → Trampoline → EndObj → Return
- Layout starts at address 0 (preamble is first instruction)
- StepId now uses u16 (0 is valid address, terminal handled by decoding logic)
@zharinov zharinov force-pushed the fix/call-site-scoping branch from 49f75b2 to 7c38b8d Compare January 5, 2026 13:51
@zharinov zharinov enabled auto-merge (squash) January 5, 2026 13:52
@zharinov zharinov merged commit 0bee91f into master Jan 5, 2026
4 checks passed
@zharinov zharinov deleted the fix/call-site-scoping branch January 5, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants